package edu.pku.se.chocolate.UI.Adapter;

import java.util.ArrayList;

import edu.pku.se.chocolate.ChocolateActivity;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class BBSlistAdapter extends BaseAdapter{
	
	public static ArrayList<String> totalList;
	public static ArrayList<String> bbsList;
	private Context mCt;
	
	public BBSlistAdapter( Context _ct, String _str)
	{
		mCt =_ct;
		totalList = ChocolateActivity.c_solver.getBBSAllForumName();
		if(_str.equals(""))
		{
			bbsList = totalList;
		}
		else
		{
			bbsList = ChocolateActivity.c_solver.getBBSforumName(_str);
		}
	}
	
	public String getForumName(int i)
	{
		return bbsList.get(i);
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return bbsList.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int arg0, View arg1, ViewGroup arg2) {
		// TODO Auto-generated method stub
		// position就是位置从0开始，convertView是Spinner,ListView中每一项要显示的view  
        // 通常return 的view也就是convertView  
        // parent就是父窗体了，也就是Spinner,ListView,GridView了.
        TextView mTextView = new TextView(mCt); 
        mTextView.setText(bbsList.get(arg0));
//        mTextView.setTextSize(15);
//        mTextView.setTextAppearance(mCt, android.R.style.TextAppearance_Large);
        mTextView.setTextAppearance(mCt, android.R.style.TextAppearance_Medium);
        mTextView.setTextColor(Color.argb(255, 127, 255, 0));
        return mTextView; 
	}

}
